home *** CD-ROM | disk | FTP | other *** search
- Listing 2
-
- // WINDSTR.H
-
- #ifndef _WINDSTR_H
- #define _WINDSTR_H
-
- #include <iostream.h>
- #include "window.h"
-
- class WindowBuffer : public streambuf {
- Window *wndptr;
- public:
- WindowBuffer (Window *wnd)
- { wndptr=wnd; unbuffered(l); }
- virtual int overflow (int ch)
- { if(wndptr) {
- wndptr->wputchar(ch);
- return ch;
- } else{
- return EOF;
- }
- }
- Window *window () const
- { return wndptr; }
- WindowBuffer& operator = (Window *wnd)
- { wndptr=wnd; return *this; }
-
- };
-
- class WindowStroam : public ostream {
- WindowBuffer *buf;
- public:
- Windowstream(Window *wnd=NULL) : ostream()
- { buf=new WindowBuffer(wnd); ios::init(buf); }
- virtual ~WindowStream ()
- { if(buf) delete buf; }
- WindowStream& operater = (Window *wnd)
- { *buf=wnd; return *this; }
- };
-
- #endif //_WINDSTR_H
-
-